/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package bpmlab.kivulifx.component;

import bpmlab.kivulifx.effects.MoveShape;
import bpmlab.kivulifx.entity.RectangleModel;
import javafx.scene.shape.Rectangle;

/**
 *
 * @author bpmlab
 */
public class KVRectangle extends Rectangle {

    private final MoveShape moveShape = new MoveShape();
    private final RectangleModel model;

    public KVRectangle(RectangleModel model) {
        this.model = model;
        this.translateXProperty().bindBidirectional(this.model.xProperty());
        this.translateYProperty().bindBidirectional(this.model.yProperty());
        this.widthProperty().bindBidirectional(this.model.widthProperty());
        this.heightProperty().bindBidirectional(this.model.heightProperty());
        this.setOnMousePressed(moveShape.getOnMousePressed());
        this.setOnMouseDragged(moveShape.getOnMouseDragged());
        this.requestFocus();
    }

    public KVRectangle() {
        this(new RectangleModel());
    }

    public RectangleModel getModel() {
        return model;
    }

}
